//
//  userDataMiddleView.swift
//  XGamesLive
//
//  Created by ios on 2024/5/20.
//

import UIKit

class XGL_UserDataMiddleView: UIView {
    
    var followItem: UIButton!
    var videoItem: UIButton!
    var messageItem: UIButton!
    var moreItem: UIButton!
    
    var asFollow: Bool = false{
        didSet{
            if asFollow{
                self.followItem.isHidden = true
                self.videoItem.isHidden = false
                self.messageItem.isHidden = false
                self.moreItem.isHidden = false
                self.snp.updateConstraints { make in
                    make.height.equalTo(54.0)
                }
            }else{
                self.followItem.isHidden = false
                self.videoItem.isHidden = true
                self.messageItem.isHidden = true
                self.moreItem.isHidden = true
                self.snp.updateConstraints { make in
                    make.height.equalTo(34.0)
                }
            }
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.followItem = UIButton().then({ make in
            make.setTitle("+ Follow", for: .normal)
            make.setTitleColor(UIColor.hexColor("#191A1D"), for: .normal)
            make.titleLabel?.font = UIFont.pingfangSC_Regular(fontSize: 16.0)
            make.backgroundColor = UIColor.hexColor("#80FFE6")
            make.layerCornerRadius = 4.0
        })
        self.videoItem = UIButton().then({ make in
            make.setImage(imageWithName("img_xgl_user_video"), for: .normal)
            make.isHidden = true
        })
        self.messageItem = UIButton().then({ make in
            make.setImage(imageWithName("img_xgl_user_message"), for: .normal)
            make.isHidden = true
        })
        self.moreItem = UIButton().then({ make in
            make.setImage(imageWithName("img_xgl_user_more"), for: .normal)
            make.isHidden = true
        })
        self.addSubviews([followItem,videoItem,messageItem,moreItem])
        followItem.snp.makeConstraints { make in
            make.centerY.height.centerX.equalToSuperview()
            make.left.equalTo(15.0)
        }
        videoItem.snp.makeConstraints { make in
            make.centerY.height.equalToSuperview()
            make.left.equalTo(15.0)
            make.width.equalTo(54.0)
        }
        messageItem.snp.makeConstraints { make in
            make.centerY.height.equalToSuperview()
            make.left.equalTo(videoItem.snp.right).offset(40.0)
            make.width.equalTo(54.0)
        }
        moreItem.snp.makeConstraints { make in
            make.centerY.height.equalToSuperview()
            make.left.equalTo(messageItem.snp.right).offset(40.0)
            make.width.equalTo(54.0)
        }
        self.snp.makeConstraints { make in
            make.height.equalTo(34.0)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
